For information about PWM in ATmega16, refer the topic PWM in ATmega16 in the ATmega inside section.
Servo Control
/* Name : main.c * Purpose : Source code for Servo Motor interface with ATMEGA16. * Author : Gemicates * Date : 2017-09-07 * Website : www.gemicates.org * Revision : None */ #ifndef F_CPU #define F_CPU 8000000UL // 8 MHz clock speed #endif #include <avr/io.h> #include <util/delay.h> int main(void) { DDRC = 0x01; // Makes RC0 output pin PORTC = 0x00; while(1) { // Rotate Motor to -90 degree PORTC = 0x01; _delay_us(1000); PORTC = 0x00; _delay_ms(2000); // Rotate Motor to 0 degree PORTC = 0x01; _delay_us(1500); PORTC = 0x00; _delay_ms(2000); // Rotate Motor to +90 degree PORTC = 0x01; _delay_us(2000); PORTC = 0x00; _delay_ms(2000); } }